/***********************************************************************
* @file           DisPlay.c
* @author         ZhaoYun(ZFSZDZ)
* @date           2024.10.12
* @Version        V1.0.0
* @description    LCD��ʾ֧���ļ�
***********************************************************************/
#include "Display.h"

void DisplayInit(void)
{
	LCD_ShowString(0,3,(unsigned char *)"BLDC Motor Controling",LIGHTBLUE,BLACK,16,0);

    LCD_ShowString(0,20,(unsigned char *)"Tempreture",YELLOW,BLACK,16,0);
    LCD_ShowString(80,20,(unsigned char *)":",WHITE,BLACK,16,0);

    LCD_ShowString(130,20,(unsigned char *)"MotorSt:",YELLOW,BLACK,16,0);

    LCD_ShowString(0,40,(unsigned char *)"PotVoltage",GREEN,BLACK,16,0);
    LCD_ShowString(80,40,(unsigned char *)":",WHITE,BLACK,16,0);

    LCD_ShowString(0,60,(unsigned char *)"AimSpeed",YELLOW,BLACK,16,0);
    LCD_ShowString(65,60,(unsigned char *)":",WHITE,BLACK,16,0);
    LCD_ShowString(108, 60, (unsigned char *)"RPM", WHITE, BLACK, 16, 0);

    LCD_ShowString(0,80,(unsigned char *)"ActSpeed",GREEN,BLACK,16,0);
    LCD_ShowString(65,80,(unsigned char *)":",WHITE,BLACK,16,0);
    LCD_ShowString(108, 80, (unsigned char *)"RPM", WHITE, BLACK, 16, 0);

    LCD_ShowString(0,100,(unsigned char *)"FaultCode",YELLOW,BLACK,16,0);
    LCD_ShowString(75,100,(unsigned char *)":",WHITE,BLACK,16,0);
               
}

void DisplayProcess(void)
{
    static enum{
        tempreture,
        potvoltage,
        aimspeed,
        actspeed,
        faultcode,
        motorState,
        sentinal,
    }eDisplayState = tempreture;
    uint16_t faultCode;
    uint16_t potADCVal;
    uint16_t u16Aimspeed;
    
    switch (eDisplayState)
    {
        case tempreture:
            LCD_ShowIntNum(90,20,100,3, BRRED, BLACK, 16);
            eDisplayState++;
            break;
        case potvoltage:
            potADCVal = u16AdcGetAverageValue(AN_DEF_POT);
            LCD_ShowIntNum(90, 40,potADCVal, 4, BRRED, BLACK, 16);
            eDisplayState++;          
            break;
        case aimspeed:
            u16Aimspeed = u16SampleSwitchPotValue();
            LCD_ShowIntNum(75, 60, u16Aimspeed, 4, BRRED, BLACK, 16);
            eDisplayState++;                  
            break;
        case actspeed:
            LCD_ShowIntNum(75,80,2005, 4, BRRED, BLACK, 16);
            eDisplayState++;                  
            break;
        case faultcode:
            faultCode = 9999;
            LCD_ShowIntNum(85,100,faultCode,calNumberLength_U16(faultCode), BRRED, BLACK,16);
            eDisplayState++;                   
            break;
        case motorState:
            LCD_ShowIntNum(195,20,eGetMotorState(),1, BRRED, BLACK,16);
            eDisplayState++;                   
            break;
        default:
            eDisplayState = sentinal;
            break;
    }
    eDisplayState %= sentinal;
}
/*******************Copyright (c) ZFSZDZ ******END OF FILE************/
